#include "Register.h"
Register::Register(HINSTANCE p_instance,HWND p_handle)
{
	this->sm_handle=p_handle;
	this->sm_instance=p_instance;
}
bool Register::InitWindow(HINSTANCE p_instance,int nCmdshow)
{
	WNDCLASSEX wc;
	wc.cbSize = sizeof(WNDCLASSEX);

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.hInstance = p_instance;

	wc.lpfnWndProc = (WNDPROC)winproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = APP_CLASS;
	wc.hIconSm = NULL;

	RegisterClassEx(&wc);

		sm_handle = 
		CreateWindow(
		APP_CLASS,
		MAIN_WINDOW_TITLE,
		WS_OVERLAPPEDWINDOW, 
		//			WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP,
		CW_USEDEFAULT,
		CW_USEDEFAULT, 
		800,
		600,
		NULL,
		NULL,
		p_instance,
		NULL);

	if (!sm_handle) { 
		DWORD ErrCode = GetLastError();
		return FALSE;
	}

	ShowWindow(sm_handle,nCmdshow);
	UpdateWindow(sm_handle);
	return true;
}
LRESULT CALLBACK Register::winproc(HWND p_handle,UINT p_msg,WPARAM p_wparam,LPARAM p_lparam)
{
	switch (p_msg) {
	case WM_DESTROY: 
		PostQuitMessage(0);
		break;
	default: 
		return DefWindowProc(p_handle, p_msg, p_wparam,p_lparam);
	}

	return 0;
}
HINSTANCE Register::GetInstance()
{
	return sm_instance;
}
HWND Register::GetHandle()
{
	return sm_handle;
}
